<?php
header("content-type:text/html;charset=utf8");
$user = $_GET['user'];
$name = $_GET['name'];
$price = $_GET['price'];
$src = $_GET['src'];
$con = mysqli_connect('localhost', 'root', 'root', 'userdata');
mysqli_query($con, 'set names utf8');
$res = mysqli_query($con, "select * from goods where name='$name' and user='$user'");
$row = mysqli_fetch_assoc($res);
if ($row) {
    $arr = [
        "meta" => [
            "status" => 0,
            "msg" => "该商品已存在"
        ]
    ];
} else {
    $res = mysqli_query($con, "insert goods(user,name,price,src) values('$user','$name','$price','$src')");
    if ($res) {
        $arr = [
            "meta" => [
                "status" => 1,
                "msg" => "添加成功"
            ]
        ];
    } else {
        $arr = [
            "meta" => [
                "status" => 2,
                "msg" => "添加失败"
            ]
        ];
    }
}

echo json_encode($arr);
